{include file="public/header"}
<body>
<fieldset class="layui-elem-field">
    <legend>管理员列表</legend>
    <div class="layui-field-box">
        <span class="layui-btn layui-btn-normal api-add"><i class="layui-icon">&#xe608;</i> 添加管理员</span>
        <table class="layui-table" lay-even>
            <thead>
            <tr>
                <th>#</th>
                <th>管理员姓名</th>
                <th>手机号码</th>
                <th>添加人员</th>
                <th>添加时间</th>
                <th>登录次数</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr>
                <td>{$i}</td>
                <td>{$vo['name']}</td>
                <td>{$vo['mobile']}</td>
                <td>{$vo['add_name']}</td>
                <td>{$vo['add_time']}</td>
                <td>{$vo['login_times']}</td>
                <td>
                    <span class="layui-btn layui-btn-danger confirm" data-id="{$vo['id']}" data-info="你确定该管理员么？" data-url="{:url('del')}">删除</span>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>

        <div>{$list->render()}</div>
    </div>
</fieldset>


{include file="public/footer"}
<script>
    layui.use(['layer'], function() {

        $('.api-add').on('click', function () {
            layer.open({
                type: 2,
                area: ['80%', '80%'],
                maxmin: true,
                content: '{:url("add")}'
            });
        });
        $('.confirm').on('click', function () {
            var ownObj = $(this);
            layer.confirm(ownObj.attr('data-info'), {
                title: "确认信息",
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    type: "POST",
                    url: ownObj.attr('data-url'),
                    data: {id:ownObj.attr('data-id')},
                    success: function(msg){
                        if( msg.errorCode == 0 ){
                            layer.msg(msg.msg,{time:1800},function(){
                                location.reload();
                            });
                        }else{
                            layer.msg(msg.msg, {
                                icon: 5,
                                shade: [0.6, '#393D49'],
                                time:1500
                            });
                        }
                    }
                });
            });
        });
    });
</script>
</body>
</html>